#include <stdio.h>
#include "io_led.h"

/*设备绑定*/
struct device_lights_i device_lights = {
    .lights_init = (device_lights_init_fn_t)device_led_init,
    .lights_set  = (device_lights_set_fn_t)device_led_set,
};

/*操作绑定*/
struct Lighter_i lsd_lights_interface = {
    .start= (lighter_start_fn_t)io_lights_start,
    .stop = (lighter_stop_fn_t)io_lights_stop,
    .get_state = (lighter_get_state_fn_t)io_lights_get_state,
};

/*初始化灯*/
int io_lights_init(struct io_lights *self)
{
    self->interface = &lsd_lights_interface;
    self->device = &device_lights;
    self->lights_state = 1;
    self->device->lights_init();
    self->device->lights_set(self->lights_state);
    return 0;
}
/*开启灯*/
int io_lights_start(struct io_lights *self)
{
    self->lights_state = 0;
    self->device->lights_set(self->lights_state);
    return 0;
}
/*关闭灯*/
int io_lights_stop(struct io_lights *self)
{
    self->lights_state = 1;
    self->device->lights_set(self->lights_state);
    return 0;
}
/*获取灯状态*/
int io_lights_get_state(struct io_lights *self)
{
    printf("io_lights_state = %d\n",self->lights_state);
    return self->lights_state;
}